<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>系统</title>
<%@include file="/WEB-INF/jsp/include/easyui_1_5_3.jsp"%>
<script type="text/javascript" src="${path}/js/business/sysUnitInfoComboTree.js"></script>
<script type="text/javascript" src="${path}/js/business/kvComboBox.js"></script>

<script type="text/javascript">
	//请求地址
	var url;
	//提示消息
	var mesTitle;
	
	//页面加载后执行
	$(function(){
// 		unitInfoComboTree('#physic_unit_form',path+'/sysUnitInfo/getBy');
// 		kvComboBox('#physic_type_form',path+'/sysDict/kvByType?pid=yplb');
// 		kvComboBox('#physic_spec_form',path+'/sysDict/kvByType?pid=药品规格');
// 		kvComboBox('#physic_unit_form',path+'/sysDict/kvByType?pid=药品单位');
// 		kvComboBox('#physic_form_form',path+'/sysDict/kvByType?pid=药品剂型');
// 		kvComboBox('#toxicology_property_form',path+'/sysDict/kvByType?pid=病理分类');
// 		kvComboBox('#material_property_form',path+'/sysDict/kvByType?pid=材质分类');
// 		kvComboBox('#item_receipt_form',path+'/sysDict/kvByType?pid=收据归属');
// 		kvComboBox('#dose_unit_form',path+'/sysDict/kvByType?pid=剂量单位');
// 		kvComboBox('#valid_flag_form',path+'/sysDict/kvByType?pid=isno');
// 		kvComboBox('#presc_flag_form',path+'/sysDict/kvByType?pid=isno');
// 		manuFactorComboBox('#manufactor_code_form',path+'/psPhysicFactoryDict/getForCombo');
		
    });
	//添加用户信息
	function addPsPhysicInDetail(){
		$('#dlg').dialog('open').dialog('setTitle','新增');
		$('#fm').form('clear');
		url=path+"/psPhysicInDetail/add";
		mesTitle = '新增成功';
	}
	
	//编辑用户信息
 	function editPsPhysicInDetail(){
	 	var row = $('#datagrid').datagrid('getSelected');
	 	if (row){
	 		var id = row.id;
		 	$('#dlg').dialog('open').dialog('setTitle','编辑');
		 	$('#fm').form('load',row);
		 	url = path+"/psPhysicInDetail/modify?id="+id;
		 	mesTitle = '编辑成功';
	 	}else{
	 		$.messager.alert('提示', '请选择要编辑的记录！', 'error');
	 	}
	}
 	
	//删除用信息
 	function deletePsPhysicInDetail(){
	 	var row = $('#datagrid').datagrid('getSelected');
	 	if (row){
	 		var id = row.id;
		 	$('#dlg_delete').dialog('open').dialog('setTitle','删除');
		 	$('#fmdelete').form('load',row);
		 	url = path+"/psPhysicInDetail/delete?id="+id;
		 	mesTitle = '删除成功';
	 	}else{
	 		$.messager.alert('提示', '请选择要删除的记录！', 'error');
	 	}
	}
 	
	//保存添加、修改内容
	function savePsPhysicInDetail(){
	 	$('#fm').form('submit',{
		 	url: url,
		 	onSubmit: function(){
		 		return $(this).form('validate');
		 	},
			success: function(result){
				/* console.info(result); */
				var result = eval('('+result+')');
				if (result.success){
				 	$('#dlg').dialog('close'); 
				 	$('#datagrid').datagrid('reload'); 
				} else {
					 mesTitle = '新增失败';
				}
				$.messager.show({ 
					timeout:5000,
					showType:'slide',
					width: 250,
					height:'30%',  
					style:{  
					    left:'',  
					    right:0,  
					    top:'',  
					    bottom:'0',
					    position:'fixed'//元素定位方式：fixed固定。 默认:absolute绝对定位 
					},
					title: mesTitle,
					msg: result.msg
				});
			}
	 	});
	}	
	
	//提交删除内容
	function savePsPhysicInDetail_del(){
	 	$('#fmdelete').form('submit',{
		 	url: url,
		 	onSubmit: function(){
		 		return $(this).form('validate');
		 	},
			success: function(result){
				/* console.info(result); */
				var result = eval('('+result+')');
				if (result.success){
				 	$('#dlg_delete').dialog('close'); 
				 	$('#datagrid').datagrid('reload'); 
				} else {
					 mesTitle = '新增失败';
				}
				$.messager.show({
					timeout:5000,
					showType:'slide',
					width: 250,
					height:'30%',  
					style:{  
					    left:'',  
					    right:0,  
					    top:'',  
					    bottom:'0',
					    position:'fixed'//元素定位方式：fixed固定。 默认:absolute绝对定位 
					},
					title: mesTitle,
					msg: result.msg
				});
			}
	 	});
	}

	//快速查询
 	function searchPsPhysicInDetailQ(){
	 	$("#datagrid").datagrid("load", {
            "username": $('#search_username').val()
        });
	}
	
	//查询
 	function searchPsPhysicInDetail(){
		$('#dlgsearch').dialog('open').dialog('setTitle','查询');
		$('#fmsearch').form('clear');
		url = path+"/user/searchUser";
		mesTitle = '查询成功';
	}
	
	//刷新
	function reload(){
		$('#datagrid').datagrid('reload'); 
	}
</script>

</head>
<body class="easyui-layout" fit="true">
	<div region="center" border="false" style="overflow: hidden;">
		<!-- 信息列表 title="管理" -->
		<table id="datagrid" class="easyui-datagrid" 
		    fit="true"
			url="${path}/psPhysicInDetail/datagrid" 
			toolbar="#toolbar" 
			pagination="true"
			fitColumns="false" 
			singleSelect="true" 
			rownumbers="true"
			striped="true"
			border="false" 
			nowrap="false">
			<thead>
				<tr>
					<!-- <th field="ck" checkbox="true"></th> -->
					<th field="id" width="100">id</th>
					<th field="department" width="100">单位ID</th>
					<th field="physic_in_sort" width="100">入库分类</th>
					<th field="inout_order_number" width="100">单据号码</th>
					<th field="physic_type" width="100">项目类别</th>
					<th field="physic_code" width="100">药品编码</th>
					<th field="physic_std_code" width="100">药品标准编码</th>
					<th field="physic_bar_code" width="100">药品条形码</th>
					<th field="physic_factory_code" width="100">药品厂家编码</th>
					<th field="physic_name_code" width="100">药名编码</th>
					<th field="physic_name" width="100">药品名称</th>
					<th field="mnemonic" width="100">拼音简码</th>
					<th field="physic_spec" width="100">规格</th>
					<th field="physic_unit" width="100">单位</th>
					<th field="physic_form" width="100">剂型</th>
					<th field="toxicology_property" width="100">毒理分类</th>
					<th field="material_property" width="100">材质分类</th>
					<th field="quantity" width="100">数量</th>
					<th field="in_price" width="100">进货价</th>
					<th field="trade_price" width="100">批发价</th>
					<th field="retail_price" width="100">零售价</th>
					<th field="storage_number" width="100">库房名称</th>
					<th field="allocation" width="100">货位</th>
					<th field="physic_batch_code" width="100">批号</th>
					<th field="valid_period" width="100">有效期</th>
					<th field="handle" width="100">操作员</th>
					<th field="handle_date" width="100">操作日期</th>
					<th field="account_sign" width="100">记帐标志</th>
					<th field="account_person" width="100">记帐人</th>
					<th field="account_date" width="100">记帐日期</th>
					<th field="tax_rate" width="100">税率</th>
					<th field="tax" width="100">税额</th>
				</tr>
			</thead>
		</table>

		<!-- 按钮 -->
		<div id="toolbar" style="padding:3px">
			<a href="javascript:void(0);" class="easyui-linkbutton"
				iconCls="icon-reload" plain="true" onclick="reload();">刷新</a>
			<a href="javascript:void(0);" class="easyui-linkbutton"
				iconCls="icon-add" plain="true" onclick="addPsPhysicInDetail();">新增</a> 
			<a href="javascript:void(0);" class="easyui-linkbutton"
				iconCls="icon-edit" plain="true" onclick="editPsPhysicInDetail();">编辑</a> 
			<a href="javascript:void(0);" class="easyui-linkbutton"
				iconCls="icon-remove" plain="true" onclick="deletePsPhysicInDetail();">删除</a>
			<span>用户名:</span>
			<input name="search_username" id="search_username" value="" size=10 /> 
  			<a href="javascript:searchPsPhysicInDetailQ()" class="easyui-linkbutton" data-options="iconCls:'icon-search'">查询</a> 
			<a href="javascript:void(0);" class="easyui-linkbutton"
				iconCls="icon-jright" plain="true" onclick="searchPsPhysicInDetail();">更多查询</a>
		</div>

		<!-- 添加/修改对话框 -->
		<div id="dlg" class="easyui-dialog"
			style="width:600px;height:400px;padding:30px 20px" closed="true"
			buttons="#dlg_AM-buttons">
			<form id="fm" method="post" novalidate>
				<table>
					<tr>
						<td>
							<label>id:</label>
						</td>
						<td>
							<input name="id" class="easyui-validatebox" required="true">
						</td>
						<td>
							<label>单位ID:</label>
						</td>
						<td>
							<input name="department" class="easyui-validatebox" required="true">
						</td>
					</tr>
					<tr>
						<td>
							<label>入库分类:</label>
						</td>
						<td>
							<input name="physic_in_sort" class="easyui-validatebox" required="true">
						</td>
						<td>
							<label>单据号码:</label>
						</td>
						<td>
							<input name="inout_order_number" class="easyui-validatebox" required="true">
						</td>
					</tr>
					<tr>
						<td>
							<label>项目类别:</label>
						</td>
						<td>
							<input name="physic_type" class="easyui-validatebox" required="true">
						</td>
						<td>
							<label>药品编码:</label>
						</td>
						<td>
							<input name="physic_code" class="easyui-validatebox" required="true">
						</td>
					</tr>
					<tr>
						<td>
							<label>药品标准编码:</label>
						</td>
						<td>
							<input name="physic_std_code" class="easyui-validatebox" required="true">
						</td>
						<td>
							<label>药品条形码:</label>
						</td>
						<td>
							<input name="physic_bar_code" class="easyui-validatebox" required="true">
						</td>
					</tr>
					<tr>
						<td>
							<label>药品厂家编码:</label>
						</td>
						<td>
							<input name="physic_factory_code" class="easyui-validatebox" required="true">
						</td>
						<td>
							<label>药名编码:</label>
						</td>
						<td>
							<input name="physic_name_code" class="easyui-validatebox" required="true">
						</td>
					</tr>
					<tr>
						<td>
							<label>药品名称:</label>
						</td>
						<td>
							<input name="physic_name" class="easyui-validatebox" required="true">
						</td>
						<td>
							<label>拼音简码:</label>
						</td>
						<td>
							<input name="mnemonic" class="easyui-validatebox" required="true">
						</td>
					</tr>
					<tr>
						<td>
							<label>规格:</label>
						</td>
						<td>
							<input name="physic_spec" class="easyui-validatebox" required="true">
						</td>
						<td>
							<label>单位:</label>
						</td>
						<td>
							<input name="physic_unit" class="easyui-validatebox" required="true">
						</td>
					</tr>
					<tr>
						<td>
							<label>剂型:</label>
						</td>
						<td>
							<input name="physic_form" class="easyui-validatebox" required="true">
						</td>
						<td>
							<label>毒理分类:</label>
						</td>
						<td>
							<input name="toxicology_property" class="easyui-validatebox" required="true">
						</td>
					</tr>
					<tr>
						<td>
							<label>材质分类:</label>
						</td>
						<td>
							<input name="material_property" class="easyui-validatebox" required="true">
						</td>
						<td>
							<label>数量:</label>
						</td>
						<td>
							<input name="quantity" class="easyui-validatebox" required="true">
						</td>
					</tr>
					<tr>
						<td>
							<label>进货价:</label>
						</td>
						<td>
							<input name="in_price" class="easyui-validatebox" required="true">
						</td>
						<td>
							<label>批发价:</label>
						</td>
						<td>
							<input name="trade_price" class="easyui-validatebox" required="true">
						</td>
					</tr>
					<tr>
						<td>
							<label>零售价:</label>
						</td>
						<td>
							<input name="retail_price" class="easyui-validatebox" required="true">
						</td>
						<td>
							<label>库房名称:</label>
						</td>
						<td>
							<input name="storage_number" class="easyui-validatebox" required="true">
						</td>
					</tr>
					<tr>
						<td>
							<label>货位:</label>
						</td>
						<td>
							<input name="allocation" class="easyui-validatebox" required="true">
						</td>
						<td>
							<label>批号:</label>
						</td>
						<td>
							<input name="physic_batch_code" class="easyui-validatebox" required="true">
						</td>
					</tr>
					<tr>
						<td>
							<label>有效期:</label>
						</td>
						<td>
							<input name="valid_period" class="easyui-validatebox" required="true">
						</td>
						<td>
							<label>操作员:</label>
						</td>
						<td>
							<input name="handle" class="easyui-validatebox" required="true">
						</td>
					</tr>
					<tr>
						<td>
							<label>操作日期:</label>
						</td>
						<td>
							<input name="handle_date" class="easyui-validatebox" required="true">
						</td>
						<td>
							<label>记帐标志:</label>
						</td>
						<td>
							<input name="account_sign" class="easyui-validatebox" required="true">
						</td>
					</tr>
					<tr>
						<td>
							<label>记帐人:</label>
						</td>
						<td>
							<input name="account_person" class="easyui-validatebox" required="true">
						</td>
						<td>
							<label>记帐日期:</label>
						</td>
						<td>
							<input name="account_date" class="easyui-validatebox" required="true">
						</td>
					</tr>
					<tr>
						<td>
							<label>税率:</label>
						</td>
						<td>
							<input name="tax_rate" class="easyui-validatebox" required="true">
						</td>
						<td>
							<label>税额:</label>
						</td>
						<td>
							<input name="tax" class="easyui-validatebox" required="true">
						</td>
					</tr>
				</table>
			</form>
		</div>
		
		<!-- 添加/修改对话框按钮 -->
		<div id="dlg_AM-buttons">
			<a href="javascript:void(0)" class="easyui-linkbutton c6"
				iconCls="icon-ok" onclick="savePsPhysicInDetail()" style="width:90px">保存</a> 
				<a href="javascript:void(0)" class="easyui-linkbutton"
				iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')"
				style="width:90px">取消</a>
		</div>
		
		<!-- 删除对话框 -->
		<div id="dlg_delete" class="easyui-dialog"
			style="width:300px;height:200px;padding:30px 20px" closed="true"
			buttons="#dlg-del-buttons">
			<div class="ftitle">请谨慎操作</div>
			<form id="fmdelete" method="post" novalidate>
					<label>确定删除吗？</label>
			</form>
		</div>
		
		<!-- 删除对话框按钮 -->
		<div id="dlg-del-buttons">
			<a href="javascript:void(0)" class="easyui-linkbutton c6"
				iconCls="icon-ok" onclick="savePsPhysicInDetail_del()" style="width:90px">删除</a> 
			<a href="javascript:void(0)" class="easyui-linkbutton"
				iconCls="icon-cancel" onclick="javascript:$('#dlg_delete').dialog('close')"
				style="width:90px">取消</a>
		</div>
		
		<!-- 查询对话框 -->
		<div id="dlgsearch" class="easyui-dialog"
			style="width:400px;height:380px;padding:30px 20px" closed="true"
			buttons="#dlg_query-buttons">
			<form id="fmsearch" method="post" novalidate>
				<label>权限:</label>  
                    <span id="span1" style="display: inline-block;"></span>  
                </div>
			</form>
		</div>
		
		<!-- 查询对话框按钮 -->
		<div id="dlg_query-buttons">
			<a href="javascript:void(0)" class="easyui-linkbutton c6"
				iconCls="icon-ok" onclick="searchPsPhysicInDetail()" style="width:90px">查询</a> 
				<a href="javascript:void(0)" class="easyui-linkbutton"
				iconCls="icon-cancel" onclick="javascript:$('#dlgsearch').dialog('close')"
				style="width:90px">取消</a>
		</div>
		
	</div>
</body>
</html>
